package basic14;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;

import javax.naming.spi.DirStateFactory.Result;

public class J23_MemberDAO implements J23_MemberService {

	private static final String DRV = "";
	private static final String URL = "";
	private static final String USR = "";
	private static final String PWD = "";

	private static final String insertSQL = "insert into members values";
	private static final String updateSQL = "";
	private static final String deleteSQL = "";
	private static final String selectSQL = "select userid, jumin, mp from member order by userid";
	private static final String selectOneSQL = "select * from members where userid=?";

	@Override
	public int insertMember(J23_Members m) {
		int cnt = 0;
		return cnt;
	}

	@Override
	public int updateMember(J23_Members m) {
		int cnt = 0;
		return cnt;
	}

	@Override
	public int deleteMember(String userid) {
		int cnt = 0;
		return cnt;
	}

	@Override
	public ArrayList<J23_Members> readMember() {
		ArrayList<J23_Members> data = new ArrayList<J23_Members>();
		Connection conn = null;
		PreparedStatement ps = null;
		ResultSet rs = null;
		try {
			Class.forName(DRV);
			conn = DriverManager.getConnection(URL, USR, PWD);
			ps = conn.prepareStatement(selectSQL);
			rs = ps.executeQuery();
			while (rs.next()) {
				J23_Members m = new J23_Members(rs.getString(1), rs.getString(2), null, null, null,
						null, rs.getString(3), null);
				// 결과집합 rs에 저장된 모든 데이터 중
				data.add(m);
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if(rs!=null)try{rs.close();}catch(Exception e){}
			if(ps!=null)try{rs.close();}catch(Exception e){}
			if(conn!=null)try{rs.close();}catch(Exception e){}
		}

		return data;

	}

	@Override
	public J23_Members readOneMember(String userid) {
		
		return null;
	}
}
